/*
 * @Autor: Ruohong Yu
 * @Date: 2021-12-14 21:46:46
 * @LastEditors: Ruohong Yu
 * @LastEditTime: 2021-12-14 21:57:33
 * @Description: file content
 * @FilePath: \mimalld:\桌面\作业\软件工程\前端\front_regit\src\assets\js\rules.js
 */

export default {
  /**
   * @description: 判断手机号
   * @param {*} str
   * @return {*}
   * @author: Ruohong Yu
   */
  // 判断手机号
  isTelCode(str) {
    var reg = /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/
    return reg.test(str)
  },

  /**
   * @description: 校验邮件地址是否合法
   * @param {*} str
   * @return {*}
   * @author: Ruohong Yu
   */
  /* 校验邮件地址是否合法 */
  IsEmail(str) {
    var reg = /^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/
    return reg.test(str)
  },

  /**
   * @description: 判断是否为数字
   * @param {*} numValue
   * @return {*}
   * @author: Ruohong Yu
   */
  IsNum(numValue) {
    var numPattern = /^\d*$/
    var result = numPattern.test(numValue)
    return result
  },

  /**
   * @description: 判断是否为汉字
   * @param {*} charValue
   * @return {*}
   * @author: Ruohong Yu
   */
  IsCharacter(charValue) {
    var reg = /^[\u4e00-\u9fa5]{0,}$/
    return reg.test(charValue)
  },

  /**
   * @description: 判断是否为日期
   * @param {*} str
   * @return {*}
   * @author: Ruohong Yu
   */
  IsDate(str) {
    var reDateTime = /^(?:19|20)[0-9][0-9]-(?:(?:0[1-9])|(?:1[0-2]))-(?:(?:[0-2][1-9])|(?:[1-3][0-1])) (?:(?:[0-2][0-3])|(?:[0-1][0-9])):[0-5][0-9]:[0-5][0-9]$/
    var isDateTime = reDateTime.test(str)
    return isDateTime
  }
}
